#include<cstdio>
#include<cstring>
#include<cmath>
using ll=long long;
constexpr ll p=998244353;
inline void swap(int&a,int&b){a^=b^=a^=b;}
int n,m;
int ans;
int l[13];
void dfs(int tm){
  if(tm>m){
    for(int i=1;i<=n;++i)
      if(l[i]!=i)return;
    ans=(ans+1)%p;
    return;
  }
  int tmp[13];
  memcpy(tmp,l+1,4*n);
  for(int i=1;i<=n;++i){
    dfs(tm+1);
    if(i<n)swap(l[i],l[i+1]);
  }
  memcpy(l+1,tmp,4*n);
  return;
}
ll pw(ll x,ll n){
  ll rs=1;
  for(;n;n>>=1,x=x*x%p)
    if(n&1)rs=rs*x%p;
  return rs;
}
int main(){
  freopen("drama.in","r",stdin);
  freopen("drama.out","w",stdout);
  scanf("%d%d",&n,&m);
  if(pow(n,m)*n<=1e9){
    dfs(1);
    printf("%d\n",ans);
  }else
    printf("%lld\n",((pw(n,m-1)-1+p)%p*pw(n-1,p-2)%p+1)%p);
  return 0;
}